#!/usr/bin/env python
######
# SYN flood handler 
# Shoufu Luo, Oct 22, 2012
######

import socket,sys
import SocketServer
import threading

if len(sys.argv) != 3:
	print "Usage: %s <ip> <port>" % sys.argv[0]
	sys.exit(1)

ip=sys.argv[1]
port=int(sys.argv[2])

class tcp_server(SocketServer.BaseRequestHandler):
	def handle(self):
		self.data = self.request.recv(1024).strip()
		print "%s wrote:" % self.client_address[0],
		print self.data
		self.request.sendall("ACK-" + self.data)

if __name__ == "__main__":
	server = SocketServer.TCPServer((ip, port), tcp_server)
	print "Server: listening on %d ..." % port
	server.serve_forever()

	print "We quit!"


		

